package com.bus.boot.web;

import com.bus.core.entity.BusSite;
import com.bus.core.entity.BusUser;

/**
 * CMS线程变量
 */
public class BusThreadVariable {
	/**
	 * 当前用户线程变量
	 */
	private static ThreadLocal<BusUser> busUserVariable = new ThreadLocal<BusUser>();
	/**
	 * 当前站点线程变量
	 */
	private static ThreadLocal<BusSite> busSiteVariable = new ThreadLocal<BusSite>();

	/**
	 * 获得当前用户
	 * 
	 * @return
	 */
	public static BusUser getUser() {
		return busUserVariable.get();
	}

	/**
	 * 设置当前用户
	 * 
	 * @param user
	 */
	public static void setUser(BusUser user) {
		busUserVariable.set(user);
	}

	/**
	 * 移除当前用户
	 */
	public static void removeUser() {
		busUserVariable.remove();
	}

	/**
	 * 获得当前站点
	 * 
	 * @return
	 */
	public static BusSite getSite() {
		return busSiteVariable.get();
	}

	/**
	 * 设置当前站点
	 * 
	 * @param site
	 */
	public static void setSite(BusSite site) {
		busSiteVariable.set(site);
	}

	/**
	 * 移除当前站点
	 */
	public static void removeSite() {
		busSiteVariable.remove();
	}
}
